﻿using CoachingOrganizer.iOS.DataSources.Tools.MoneyCalculation;
using CoachingOrganizer.iOS.Helpers;
using CoachingOrganizer.Logic.Models.Tools.MoneyCalculation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoachingOrganizer.iOS.Controllers.Tools.MoneyCalculation
{
    public partial class OccasionalSpentsMoneyCalculationDetailsViewController : UIViewController
    {
        private readonly MoneyCalculationModel _model;

        public OccasionalSpentsMoneyCalculationDetailsViewController(IntPtr handle)
            : base(handle)
        {
            _model = ((SpentsMoneyCalculationDetailsViewController)ParentViewController).Model;
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //ItemNameView   //AutoCompleteTextField ???
            UIHelper.RegisterCellClass(ItemsView, OccasionalSpentsDataSource.CellIdentifer);
            ItemsView.Source = new OccasionalSpentsDataSource(ItemsView, this, _model);
        }

        partial void AddNewItem(NSObject sender)
        {
            _model.AddNewOccasionalSpent(ItemNameView.Text);
        }

        partial void GoBack(NSObject sender)
        {
            ParentViewController.ParentViewController.DismissViewController(true, null);
        }
    }
}
